/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controlador;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import javax.persistence.EntityManager;
import javax.persistence.Query;

/**
 *
 * @author Mike
 */
class resultSetType {

    
     public static List retornarConsultaComoObjetos (EntityManager em,String sql, Class tipoObjeto)
    {
        
        em.getTransaction().begin();
        
        Query query = em.createNativeQuery(sql, tipoObjeto);
        List rta =  query.getResultList();
                
        em.getTransaction().commit();
        em.close();

        return rta; 
    }
    

    
    
    
    public static ArrayList<Object[]> retornarConsultaMultiplesCadenas (EntityManager em, String sql)
    {

       
       em.getTransaction().begin();
        
      
       Query query = em.createNativeQuery(sql);
       List<Object[]> results = (List<Object[]>) query.getResultList();
        
        
       em.getTransaction().commit();
       em.close();
        
       return (new  ArrayList<>(results));
        

    }
    
        public static  List<String> retornarConsultaCadenasSimples (EntityManager em, String sql)
    {

       
       em.getTransaction().begin();
        
      
       Query query = em.createNativeQuery(sql);
       List<String> results = (List<String>) query.getResultList();
        
        
       em.getTransaction().commit();
       em.close();
        
       return results;
        

    }
    
    
    
}
